<?php

/*
 * this is a function to validate the validation code format
 *
 */
function validateVCode($vCode) {
    if ( !(preg_match('/^[a-zA-Z]{5}$/', $vCode)) ){
        return false;
    }
    else{
        return true;}
}

// validate input from the forms
function validateUserName($userName){
    $isValid = FALSE;
if ( preg_match('/^[a-zA-Z0-9]{3,20}$/',$userName))
   $isValid = TRUE;
return $isValid;
}

function validateUserPostcode($userPostcode){
    $isValid = FALSE;
if ( preg_match('/^[a-zA-Z][a-zA-Z0-9]{1,3}[0-9][a-zA-z][a-zA-z]$/',$userPostcode) ) 
   $isValid = TRUE;
return $isValid;
}

function validateUserEmail($userEmail){
    $isValid = FALSE;
if ( !preg_match('/^([\w\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/',$userEmail) )
   $isValid = TRUE;
return $isValid;
}

function validateUserPassword($userPassword){
    $isValid = FALSE;
if ( !preg_match('/^[a-zA-Z0-9]{8,20}$/',$userPassword) || !preg_match('/[A-Z]/', $userPassword) 
       || !preg_match('/[a-z]/', $userPassword) 
       || !preg_match('/[0-9]/', $userPassword))//net tuts : Vasili
   $isValid = TRUE;
return $isValid;
}
//if (userNameAlreadyAssignDb($userName))
//    $strValid .= " user name already assign please choose another<br />\n";

?>
